<?php

$this->LoadHelper('MemberHelper');
$MemberHelper = new MemberHelper();

$this->LoadHelper('DepartmentHelper');
$DepartmentHelper = new DepartmentHelper();

$this->LoadHelper('RoleHelper');
$RoleHelper = new RoleHelper();

$role_msg = $RoleHelper->roleName(array('`r_status` =?' =>'ok'));
$ajax = $this->Param['ajax'];
$page = isset($this->Param['page']) ? $this->Param['page'] : 1;
$rp = isset($this->Param['rp']) ? $this->Param['rp'] : PAGE_SIZE;

if ($ajax) {
    $data = $MemberHelper->pageList($where, $page, $rp, $this->Param);
    $json_data = array('total' => $data['count'], 'rows' => array());
    if(!empty($data['all'])){
        foreach ($data['all'] AS $rowNum => $row) {
            $dpinfo = $MemberHelper->getDpinfo($row);
            $row['u_dpname'] = $dpinfo['dpname'];
            $row['u_role'] = $role_msg[$row['u_role']];
            $row['u_status'] = $row['u_status'] == 'ok'? '正常':'注销';
            $row['u_addtime'] = date('Y-m-d H:i:s', $row['u_addtime']);
            $json_data['rows'][] = $row;
        }
    }
    echo json_encode($json_data);
} else {
    $member_info = $MemberHelper->getMember($this->UserConfig['Id']);
    $this->Assign('member_info', $member_info);
    echo $this->GetView('index.php');
}